home *** CD-ROM | disk | FTP | other *** search
- -- card: 62691 from stack: in
- -- bmap block id: 0
- -- flags: 0000
- -- background id: 4755
- -- name:
-
-
- -- part 1 (field)
- -- low flags: 00
- -- high flags: 0007
- -- rect: left=30 top=78 right=296 bottom=478
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 4
- -- text size: 9
- -- style flags: 0
- -- line height: 12
- -- part name:
-
-
- -- part contents for card part 1
- ----- text -----
- /*
- * FILE: class.c
- * AUTHOR: R.G.
- * CREATED: August 4, 1990
- *
- * Defines root class methods as well as the new_init(), and
- * destroy_delete() functions replacing new() and delete().
- */
-
- # include "class.h"
- # include <stdlib.h>
- # include <oops.h>
-
- /******************************************************************
- * Generic class initialization
- ******************************************************************/
- boolean Generic_Class::init(void)
- {
- return TRUE;
- }
-
- /******************************************************************
- * Generic class termination
- ******************************************************************/
- boolean Generic_Class::destroy(void)
- {
- return TRUE;
- }
-
- /******************************************************************
- * Function to simulate automated initialization. Returns FALSE if
- * unable to 'new' OR if init method fails. In the latter case, the
- * object is 'deleted' without being destroyed, since it is assumed
- * that a failing init method will deallocate any space it has
- * allocated itself. The programmer must enforce this for all
- * his/her classes.
- *
- * IMPORTANT: This function does not work in C++. It is only in
- * Think C that a class name may be considered a void pointer and
- * may be passed as an argument to a function. See the comment
- * in the header file.
- ******************************************************************/
- void *new_init(void *cclass)
- /* note: class names are void pointers in TC
- */
- {
- Generic_Class *object;
-
- # ifdef INDIRECT
- object = new(cclass);
- # else
- object = malloc((size_t) (*(int *) cclass));
- /* class size is stored in first two bytes of cclass; this gets it!
- */
- blessD(object,cclass);
- # endif
-
- if (object == NULL)
- return NULL;
- else
- {
- if (!object->init())
- {
- # ifdef INDIRECT
- delete(object);
- # else
- free(object);
- # endif
- return NULL;
- }
- else
- return object;
- }
- }
-
- /******************************************************************
- * Function to simulate automated deallocation. Object must have
- * been allocated and init'ed already.
- ******************************************************************/
- void destroy_delete(Generic_Class *object)
- {
- object->destroy();
- # ifdef INDIRECT
- delete(object);
- # else
- free(object);
- # endif
- }
-
-
-
- -- part contents for background part 7
- ----- text -----
- 211
-
- -- part contents for background part 4
- ----- text -----
- File 2 of 2:
-
- -- part contents for background part 17
- ----- text -----
- p3